Fixes PR21157 'tuple: non-default constructible tuple hard failure' Thanks to Louis Dionne for the bug report and the patch. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@219785 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/tuple b/include/tuple index 1463170..aa7185c 100644 --- a/include/tuple +++ b/include/tuple
@@ -376,19 +376,18 @@ _LIBCPP_INLINE_VISIBILITY void __swallow(_Tp&&...) _NOEXCEPT {} -template <bool ...> struct __all; +template <bool ..._B> +struct __all + : is_same<__all<_B...>, __all<(_B, true)...>> +{ }; -template <> -struct __all<> -{ - static const bool value = true; -}; +template <class _Tp> +struct __all_default_constructible; -template <bool _B0, bool ... _Bp> -struct __all<_B0, _Bp...> -{ - static const bool value = _B0 && __all<_Bp...>::value; -}; +template <class ..._Tp> +struct __all_default_constructible<__tuple_types<_Tp...>> + : __all<is_default_constructible<_Tp>::value...> +{ }; // __tuple_impl @@ -512,6 +511,9 @@ typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; public: + template <bool _Dummy = true, class _Up = typename enable_if< + __all<(_Dummy && is_default_constructible<_Tp>::value)...>::value + >::type> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR tuple() _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {} @@ -547,6 +549,12 @@ sizeof...(_Up) < sizeof...(_Tp) ? sizeof...(_Up) : sizeof...(_Tp)>::type + >::value && + __all_default_constructible< + typename __make_tuple_types<tuple, sizeof...(_Tp), + sizeof...(_Up) < sizeof...(_Tp) ? + sizeof...(_Up) : + sizeof...(_Tp)>::type >::value, bool >::type = false @@ -587,6 +595,12 @@ sizeof...(_Up) < sizeof...(_Tp) ? sizeof...(_Up) : sizeof...(_Tp)>::type + >::value && + __all_default_constructible< + typename __make_tuple_types<tuple, sizeof...(_Tp), + sizeof...(_Up) < sizeof...(_Tp) ? + sizeof...(_Up) : + sizeof...(_Tp)>::type >::value, bool >::type =false @@ -620,6 +634,12 @@ sizeof...(_Up) < sizeof...(_Tp) ? sizeof...(_Up) : sizeof...(_Tp)>::type + >::value && + __all_default_constructible< + typename __make_tuple_types<tuple, sizeof...(_Tp), + sizeof...(_Up) < sizeof...(_Tp) ? + sizeof...(_Up) : + sizeof...(_Tp)>::type >::value >::type >